package com.ezerg.async;

import java.util.concurrent.CompletableFuture;

public class CompletableFutureTest {
    public static void main(String[] args) {
        CompletableFuture<String> future = CompletableFuture.supplyAsync(()->{
            System.out.println("带有返回值的异步任务"+Thread.currentThread().getName());
            return "a future value";
        }).thenApplyAsync((String str)->{
            return "-"+str;
        });
        CompletableFuture<Void> future2 = CompletableFuture.runAsync(()->{
            System.out.println("不带返回值的异步任务"+Thread.currentThread().getName());
        });
    }
}
